#! /bin/bash

set -e

pr_info () {
    echo -e "\033[0;32m$*\033[0m"
}

cd_bbb () {
    if [ -z $BBB_WS ]; then
        echo "No env: BBB_WS"
        exit
    fi
    cd $BBB_WS
}

rm -rf output/

pr_info "[build] linux defconfig"
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- O=output omap2plus_defconfig -j `nproc`

pr_info "[build] linux zImage"
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- O=output zImage -j `nproc`

pr_info "[build] linux dtb"
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- O=output ti/omap/am335x-boneblack.dtb -j `nproc`

pr_info "[build] linux modules"
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- O=output modules -j `nproc`
